<#assign keys=prenode_fileinfo_map?keys>
<script>

addLoadEvent(function() {
	$.validator.addMethod("validatelinelength",function(value,element,params){
		var yearArray = $("input[datarule='number']",'.linesegtr');
		var value = Number($(element).val());
		var currentTotalLength = Number(null);
		for(var i=0;i<yearArray.length;i++) {
			var evalCost = yearArray[i];
			currentTotalLength = currentTotalLength + Number($(evalCost).val());
		}
		if(Number(currentTotalLength)>$("#planLineLength").val()){
			return false;
		}else{
			return true;
		}
	},'协办单位线路长度总和不能大于线路建设规模！');
	$("input[datarule='number']",'.linesegtr').each(function(){
		var optionRule = {};
		optionRule["validatelinelength"] = true;				
		$(this).rules("add", optionRule);
	});
	validatorForm();
})
</script>
<#-- 定义宏，输出必填红星号 -->
<#macro renderMandatory param="false">
<#if (!formField.readonly?? || formField.readonly=="0") && param=="true">
	<span class="placeholder fontRed">*</span>
</#if>
</#macro>

<input type=hidden name="fieldMap['${field.name}'].id"  <#if businessInstanceField?? && businessInstanceField.id??>value="${businessInstanceField.id}"</#if>>
<input type=hidden name="fieldMap['${field.name}'].field.id"  value="${formField.field.id}">


	<input type=hidden id=${field.name} name="fieldMap['${field.name}'].value" <#if businessInstanceField??>value="${businessInstanceField.value?default('')}"</#if>></input>
	
	<#if pp_assistant_company_list?? && pp_assistant_company_list?size gt 0>
		<#assign index=1>
		<#assign assistantCompany_yes = false>
		<#list pp_assistant_company_list as ppac>
		<#-- 判定是协办单位登录 -->
		<#if current_user_company_id == ppac.company.id>	
		<tr id="${field.name}tr${index}" class="listviewTR linesegtr">
		
			<td class="listviewTD" align="right">单位:</td>
			
			<td class="listviewContent" align="left">
				<input type="hidden" name="fieldMap['${field.name}'].assistantCompanyList[${index}].id" value="${ppac.id?default('')}">
				${ppac.company.name?default('')}
				<input type="hidden" name="fieldMap['${field.name}'].assistantCompanyList[${index}].company.id" id="lineSegRegionId${index}" value="<#if ppac?? && ppac.company??>${ppac.company.id?default('')}</#if>">
			</td>	
				
			
			
			
				<td class="listviewTD" align="right">
					<span style="color:red;">*</span>线路长度:
				</td>
				<td class="listviewContent" align="left">
					<input type="text" class="text" style="width:133px;" name="fieldMap['${field.name}'].assistantCompanyList[${index}].length" <#if ppac.length??>value="${ppac.length?c}"</#if> datarule="number" datarulejson='{"displayName":"分段长度","dataType":"number","precision":"6","isRequired":"1","length":"8"}' >
					&nbsp;&nbsp;km</td>
			
				<td class="listviewContent" colspan="4" >&nbsp;</td>
			
			
		</tr>
		

		
		<#assign assistantCompany_yes = true>
		<#break>
		</#if>
		<#assign index=index+1>
		</#list>
		
		<#-- 判定不是协办单位登录，则显示所有协办单位信息 -->
		<#if !assistantCompany_yes>
			<#assign index=1>
			<#list pp_assistant_company_list as ppac>
				<tr id="${field.name}tr${index}" class="listviewTR linesegtr">
				<td class="listviewTD" align="right">
				
				单位:
				</td>
				
					<td class="listviewContent" align="left">
						<input type="hidden" name="fieldMap['${field.name}'].assistantCompanyList[${index}].id" value="${ppac.id?default('')}">
						${ppac.company.name?default('')}
						<input type="hidden" name="fieldMap['${field.name}'].assistantCompanyList[${index}].company.id" id="lineSegRegionId${index}" value="<#if ppac?? && ppac.company??>${ppac.company.id?default('')}</#if>">
					</td>
					
					<td class="listviewTD" align="right">
						<span style="color:red;">*</span>线路长度:
					</td>
					<td class="listviewContent" align="left">
						<input type="text" class="text" style="width:133px;" name="fieldMap['${field.name}'].assistantCompanyList[${index}].length" <#if ppac.length??>value="${ppac.length?c}"</#if> datarule="number" datarulejson='{"displayName":"分段长度","dataType":"number","precision":"6","isRequired":"1","length":"8"}' >
						&nbsp;&nbsp;km</td>
					<td class="listviewContent" colspan="4" >&nbsp;</td>
				</tr>
		
			<#assign index=index+1>
				</#list>
		</#if>
		
	</#if>